﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iNet.Tasks;

namespace iNet.Media.Imaging
{
	/// <summary>
	/// 影像編碼工作的基底類別。
	/// </summary>
	public abstract class ImageEncodeTask : MediaEncodeTask
	{
		#region 欄位
		IImage _EncodingImage;
		ImageEncodeRequests _ImageEncodeRequests;
		#endregion
		#region 建構子
		/// <summary>
		/// 初始化新的 ImageEncodeTask 執行個體。
		/// </summary>
		/// <param name="encodingFormat">影像編碼格式。</param>
		/// <exception cref="ArgumentNullException">encodingFormat 為 Null (Visual Basic 為 Nothing)。</exception>
		protected ImageEncodeTask(IMediaFormat encodingFormat)
			: base(encodingFormat)
		{ }
		/// <summary>
		/// 初始化新的 ImageEncodeTask 執行個體。
		/// </summary>
		/// <param name="encodingFormat">影像編碼格式。</param>
		/// <param name="destination">儲存編碼結果的媒體儲存。</param>
		/// <param name="mediaEncodeReqs">媒體編碼請求。</param>
		/// <param name="imageEncodeReqs">影像編碼請求。</param>
		/// <exception cref="ArgumentNullException">encodingFormat 為 Null (Visual Basic 為 Nothing)。</exception>
		protected ImageEncodeTask(IMediaFormat encodingFormat, MediaStorage destination, MediaEncodeRequests mediaEncodeReqs, ImageEncodeRequests imageEncodeReqs)
			: base(encodingFormat, destination, mediaEncodeReqs)
		{
			_ImageEncodeRequests = imageEncodeReqs;
		}
		#endregion
		#region Encode
		protected override bool Encode(TaskVersion version, MediaStorage destination, MediaEncodeRequests mediaEncodeReqs)
		{
			return this.Encode(version, destination, mediaEncodeReqs, _ImageEncodeRequests);
		}
		/// <summary>
		/// 將影像編碼。
		/// </summary>
		/// <param name="version">工作版本。</param>
		/// <param name="destination">儲存編碼結果的媒體儲存。</param>
		/// <param name="mediaEncodeReqs">媒體編碼請求。</param>
		/// <param name="imageEncodeReqs">影像編碼請求。</param>
		/// <returns>True 表示編碼完成，False 表示編碼失敗。</returns>
		protected abstract bool Encode(TaskVersion version, MediaStorage destination, MediaEncodeRequests mediaEncodeReqs, ImageEncodeRequests imageEncodeReqs);
		#endregion
		#region EncodingImage
		/// <summary>
		/// 取得或設定編碼的影像。
		/// </summary>
		public virtual IImage EncodingImage
		{
			get
			{
				return _EncodingImage;
			}
			set
			{
				this.SetInitializingParameter<IImage>(ref _EncodingImage, value);
			}
		}
		#endregion
		#region ImageEncodeRequests
		/// <summary>
		/// 取得或設定影像的編碼請求組合。
		/// </summary>
		public ImageEncodeRequests ImageEncodeRequests
		{
			get
			{
				return _ImageEncodeRequests;
			}
			set
			{
				this.SetInitializingParameter<ImageEncodeRequests>(ref _ImageEncodeRequests, value);
			}
		}
		#endregion
		#region SupportedImageEncodeRequests
		/// <summary>
		/// 取得支援的影像編碼請求組合。
		/// </summary>
		public virtual ImageEncodeRequests SupportedImageEncodeRequests
		{
			get
			{
				return ImageEncodeRequests.EncodeImage;
			}
		}
		#endregion
	}
	#region ImageEncodeRequests
	/// <summary>
	/// 表示影像編碼的請求組合。
	/// </summary>
	[Flags]
	public enum ImageEncodeRequests
	{
		/// <summary>
		/// 將影像編碼。
		/// </summary>
		EncodeImage = 0x1,
	}
	#endregion
}
